From: Joey Hess Date: Mon, 26 Sep 2022 16:55:51 +0000 (-0400) Subject: handle upgrading repositories initialized with --version=9 X-Git-Tag: archive/raspbian/10.20250416-2+rpi1~1^2~69^2~47 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=e05dd7054480ea3bf98df43bf013a34281cb2e8d;p=git-annex.git handle upgrading repositories initialized with --version=9 As was attempted earlier in the buggy commit 0d2e3058ee01d55dc3b929ddf8e0573a95a2ca85 Avoided the bug that had by making the upgrade log be updated after each upgrade step. So, after upgrade from v8 to v9, the log is updated, and so Upgrade.V9's timeOfUpgrade check will find that it was upgraded recently and so won't let it skip ahead to v10. Sponsored-by: k0ld on Patreon --- diff --git a/Upgrade.hs b/Upgrade.hs index 2073b1bec0..244050444f 100644 --- a/Upgrade.hs +++ b/Upgrade.hs @@ -74,31 +74,24 @@ needsUpgrade v Left ex -> err $ "Automatic upgrade exception! " ++ show ex upgrade :: Bool -> RepoVersion -> Annex Bool -upgrade automatic destversion = do - startversion <- getVersion - (ok, newversion) <- go startversion - when (ok && newversion /= startversion) $ - postupgrade newversion - return ok +upgrade automatic destversion = go =<< getVersion where go (Just v) - | v >= destversion = return (True, Just v) + | v >= destversion = return True | otherwise = ifM upgradingRemote ( upgraderemote , up v >>= \case - UpgradeSuccess -> go (Just (incrversion v) ) - UpgradeFailed -> return (False, Just v) - UpgradeDeferred -> return (True, Just v) + UpgradeSuccess -> do + let v' = incrversion v + upgradedto v' + go (Just v') + UpgradeFailed -> return False + UpgradeDeferred -> return True ) - go Nothing = return (True, Nothing) + go Nothing = return True incrversion v = RepoVersion (fromRepoVersion v + 1) - postupgrade newversion = ifM upgradingRemote - ( reloadConfig - , maybe noop upgradedto newversion - ) - #ifndef mingw32_HOST_OS up (RepoVersion 0) = Upgrade.V0.upgrade up (RepoVersion 1) = Upgrade.V1.upgrade @@ -121,15 +114,18 @@ upgrade automatic destversion = do -- upgrading a git repo other than the current repo. upgraderemote = do rp <- fromRawFilePath <$> fromRepo Git.repoPath - gitAnnexChildProcess "upgrade" + ok <- gitAnnexChildProcess "upgrade" [ Param "--quiet" , Param "--autoonly" ] (\p -> p { cwd = Just rp }) (\_ _ _ pid -> waitForProcess pid >>= return . \case - ExitSuccess -> (True, Nothing) - _ -> (False, Nothing) + ExitSuccess -> True + _ -> False ) + when ok + reloadConfig + return ok upgradedto v = do setVersion v diff --git a/Upgrade/V9.hs b/Upgrade/V9.hs index 124e285498..21c73fe5fb 100644 --- a/Upgrade/V9.hs +++ b/Upgrade/V9.hs @@ -40,12 +40,13 @@ upgrade automatic - and it is not safe for such to still be running after - this upgrade. -} oldprocessesdanger = timeOfUpgrade (RepoVersion 9) >>= \case - Nothing -> pure True Just t -> do now <- liftIO getPOSIXTime if now < t + 365*24*60*60 then return True else assistantrunning + -- Initialized at v9, so no old process danger exists. + Nothing -> pure False {- Skip upgrade when git-annex assistant (or watch) is running, - because these are long-running daemons that could conceivably diff --git a/doc/bugs/v8_repo_auto_upgrades_to_v10.mdwn b/doc/bugs/v8_repo_auto_upgrades_to_v10.mdwn index 023f8c694c..c9f294ed92 100644 --- a/doc/bugs/v8_repo_auto_upgrades_to_v10.mdwn +++ b/doc/bugs/v8_repo_auto_upgrades_to_v10.mdwn @@ -16,3 +16,4 @@ git config annex.version 10.20220822 Linux +> [[fixed|done]] --[[Joey]] diff --git a/doc/bugs/v8_repo_auto_upgrades_to_v10/comment_1_446aa74f0b54918dc8737483e3e8564a._comment b/doc/bugs/v8_repo_auto_upgrades_to_v10/comment_1_446aa74f0b54918dc8737483e3e8564a._comment index 552276d453..c9f786c0bd 100644 --- a/doc/bugs/v8_repo_auto_upgrades_to_v10/comment_1_446aa74f0b54918dc8737483e3e8564a._comment +++ b/doc/bugs/v8_repo_auto_upgrades_to_v10/comment_1_446aa74f0b54918dc8737483e3e8564a._comment @@ -8,7 +8,7 @@ which was included in version 10.20220822. I've reverted the commit as a first step. This means repos initialized at v9 will never autoupgrade to v10, which will need to be fixed -somehow. +somehow. (Update: Fixed that now.) Gonna need to make a git-annex release ASAP to get this fix out there. """]]